package tasks;

import org.apache.ibatis.session.*;

import ilender.util.*;
import ilender.mappers.*;
import ilender.models.*;

public final class AddCategory{
	/*Instantiation Guard*/private AddCategory(){}

	/**
	 * Add a new category.
	 *
	 * @param args First argument must be the name for the new category.
	 */
	public static void main(String[] args) throws Exception{
		SqlSession session=MyBatisTools.openSession();
		try{
			CategoriesMapper mapper=session.getMapper(CategoriesMapper.class);
			MCategory category=new MCategory();
			category.setName(args[0].trim());
			category.save(mapper);
			session.commit();
		}finally{
			session.close();
		}
	}
}
